using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace 阿里妈妈登录
{
	public class MockInput
	{
		public enum MouseEventFlags
		{
			Absolute = 32768,
			LeftDown = 2,
			LeftUp = 4,
			MiddleDown = 32,
			MiddleUp = 64,
			Move = 1,
			RightDown = 8,
			RightUp = 16,
			Wheel = 2048
		}
		public static uint KEYEVENTF_KEYUP = 2u;
		public static void click(int int_0, int int_1)
		{
			MockInput.SetCursorPos(int_0, int_1);
			MockInput.mouse_event(32770, int_0, int_1, 0, IntPtr.Zero);
			MockInput.mouse_event(32772, int_0, int_1, 0, IntPtr.Zero);
		}
		public static void click(IntPtr hwnd, int int_0, int int_1)
		{
			MockInput.SetForegroundWindow(hwnd);
			MockInput.SetCursorPos(int_0, int_1);
			MockInput.mouse_event(32770, int_0, int_1, 0, IntPtr.Zero);
			MockInput.mouse_event(32772, int_0, int_1, 0, IntPtr.Zero);
		}
		public static byte getkeycode(char char_0)
		{
			switch (char_0)
			{
			case '*':
				return 106;
			case '+':
				return 107;
			case '-':
				return 109;
			case '.':
				return 110;
			case '/':
				return 111;
			case '0':
				return 96;
			case '1':
				return 97;
			case '2':
				return 98;
			case '3':
				return 99;
			case '4':
				return 100;
			case '5':
				return 101;
			case '6':
				return 102;
			case '7':
				return 103;
			case '8':
				return 104;
			case '9':
				return 105;
			case 'a':
				return 65;
			case 'b':
				return 66;
			case 'c':
				return 67;
			case 'd':
				return 68;
			case 'e':
				return 69;
			case 'f':
				return 70;
			case 'g':
				return 71;
			case 'h':
				return 72;
			case 'i':
				return 73;
			case 'j':
				return 74;
			case 'k':
				return 75;
			case 'l':
				return 76;
			case 'm':
				return 77;
			case 'n':
				return 78;
			case 'o':
				return 79;
			case 'p':
				return 80;
			case 'q':
				return 81;
			case 'r':
				return 82;
			case 's':
				return 83;
			case 't':
				return 84;
			case 'u':
				return 85;
			case 'v':
				return 86;
			case 'w':
				return 87;
			case 'x':
				return 88;
			case 'y':
				return 89;
			case 'z':
				return 90;
			}
			return 0;
		}
		public static void input(string string_0, int sleepSec)
		{
			for (int i = 0; i < string_0.Length; i++)
			{
				if (sleepSec != 0)
				{
					Thread.Sleep(sleepSec);
				}
				MockInput.press_key(string_0.Substring(i, 1).ToCharArray()[0]);
			}
		}
		public static void inputAndClick(string string_0, int sleepSec, IntPtr hwnd, int int_0, int int_1)
		{
			for (int i = 0; i < string_0.Length; i++)
			{
				if (sleepSec != 0)
				{
					Thread.Sleep(sleepSec);
				}
				MockInput.SetForegroundWindow(hwnd);
				MockInput.SetCursorPos(int_0, int_1);
				MockInput.mouse_event(32770, int_0, int_1, 0, IntPtr.Zero);
				MockInput.mouse_event(32772, int_0, int_1, 0, IntPtr.Zero);
				MockInput.press_key(char.Parse(string_0.Substring(i, 1)));
			}
		}
		public static void Key_BackSpace()
		{
			MockInput.keybd_event(8, 0, 0u, 0u);
			MockInput.keybd_event(8, 0, MockInput.KEYEVENTF_KEYUP, 0u);
		}
		public static void Key_Enter()
		{
			MockInput.keybd_event(13, 0, 0u, 0u);
			MockInput.keybd_event(13, 0, MockInput.KEYEVENTF_KEYUP, 0u);
		}
		public static void Key_ESC()
		{
			MockInput.keybd_event(27, 0, 0u, 0u);
			MockInput.keybd_event(27, 0, MockInput.KEYEVENTF_KEYUP, 0u);
		}
		[DllImport("user32.dll", SetLastError = true)]
		public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
		[DllImport("User32")]
		public static extern void mouse_event(int dwFlags, int int_0, int int_1, int dwData, IntPtr dwExtraInfo);
		public static void mouseMove(int int_0, int int_1, int int_2)
		{
			MockInput.SetCursorPos(int_0, int_1);
			int num = (int_2 - int_0) / 9;
			MockInput.mouse_event(32770, int_0, int_1, 0, IntPtr.Zero);
			for (int i = 0; i < num + 1; i++)
			{
				MockInput.SetCursorPos(int_0 + i * 9, int_1);
				Thread.Sleep(20);
			}
			MockInput.mouse_event(32772, int_2, int_1, 0, IntPtr.Zero);
		}
		public static void Multi_Ctrl_Any(byte byte_0)
		{
			MockInput.keybd_event(17, 0, 0u, 0u);
			MockInput.keybd_event(byte_0, 0, 0u, 0u);
			MockInput.keybd_event(17, 0, MockInput.KEYEVENTF_KEYUP, 0u);
			MockInput.keybd_event(byte_0, 0, MockInput.KEYEVENTF_KEYUP, 0u);
		}
		public static void MultiKey_Ctrl_A()
		{
			MockInput.Multi_Ctrl_Any(65);
		}
		public static void MultiKey_Ctrl_C()
		{
			MockInput.Multi_Ctrl_Any(67);
		}
		public static void MultiKey_Ctrl_Enter()
		{
			MockInput.Multi_Ctrl_Any(13);
		}
		public static void MultiKey_Ctrl_V()
		{
			MockInput.Multi_Ctrl_Any(86);
		}
		public static void press_key(char char_0)
		{
			byte bVk = MockInput.getkeycode(char_0);
			MockInput.keybd_event(bVk, 0, 0u, 0u);
			MockInput.keybd_event(bVk, 0, MockInput.KEYEVENTF_KEYUP, 0u);
		}
		public void sendKey(IntPtr hwnd, string string_0)
		{
			for (int i = 0; i < string_0.Length; i++)
			{
				Thread.Sleep(10);
				MockInput.SetForegroundWindow(hwnd);
				SendKeys.SendWait(string_0.Substring(i, 1));
			}
		}
		public void sendKeyPwd(IntPtr hwnd, string string_0, int int_0, int int_1)
		{
			for (int i = 0; i < string_0.Length; i++)
			{
				Thread.Sleep(200);
				MockInput.SetForegroundWindow(hwnd);
				MockInput.SetCursorPos(int_0, int_1);
				MockInput.mouse_event(32770, int_0, int_1, 0, IntPtr.Zero);
				MockInput.mouse_event(32772, int_0, int_1, 0, IntPtr.Zero);
				SendKeys.SendWait(string_0.Substring(i, 1));
			}
		}
		[DllImport("User32")]
		public static extern void SetCursorPos(int int_0, int int_1);
		[DllImport("user32.dll", SetLastError = true)]
		private static extern void SetForegroundWindow(IntPtr intptr_0);
	}
}
